function sendMessageToContentScript(message, callback) {
    chrome.tabs.query({ active: true, currentWindow: true }, function (tabs) {
        chrome.tabs.sendMessage(tabs[0].id, message, function (response) {
            if (callback) callback(response)
        })
    })
}

chrome.webRequest.onCompleted.addListener(
    res => {
        sendMessageToContentScript({ cmd: 'url', value: res })
    },
    {
        urls: [
            "https://*.amap.com/service/poiInf*",
            "https://map.baidu.com/?newmap=1&reqflag=pcmap*"
        ]
    })
